package Server.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * Entity - 用户优惠劵
 *
 * @author xvzhe
 * @version 0.1
 *
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
public class UsersSale {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name="NumberIdProduce", strategy="Server.tool.NumberIdProduce")
    private String uuid;

    @ManyToOne
    @JoinColumn(name = "userId")
    private  Users users;

    @ManyToOne
    @JoinColumn(name = "saleId")
    private  Sale sale;




    @CreatedDate
    @Column
    private Date createTime;

    @LastModifiedDate
    @Column
    private Date modifiedTime;

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum Status {
        ING("未使用"),
        NO("已使用");
        Status(String display) {
            this.display = display;
        }
        private String display;

        public String getDisplay() {
            return display;
        }

        public void setDisplay(String display) {
            this.display = display;
        }
    }

    @Enumerated(EnumType.STRING)
    @Column
    private Status status;

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public Users getUsers() {
        return users;
    }

    public void setUsers(Users users) {
        this.users = users;
    }

    public Sale getSale() {
        return sale;
    }

    public void setSale(Sale sale) {
        this.sale = sale;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifiedTime() {
        return modifiedTime;
    }

    public void setModifiedTime(Date modifiedTime) {
        this.modifiedTime = modifiedTime;
    }

}
